﻿@model IEnumerable<sBlog.Net.Domain.Entities.PostEntity>
<script type="text/javascript">
    //    var i = 0;
    //    setInterval(function () {
    //        if (i == 3) {
    //            i = 0;
    //        }
    //        if (i == 0) {
    //            loadMostView('bai-viet');
    //        }
    //        else if (i == 1) {
    //            loadMostView('hinh-anh');
    //        }
    //        else if (i == 2) {
    //            loadMostView('video');
    //        }
    //        i++;
    //    }, 5000);

    function callLoadMoreByClick(catslug) {
        loadMostView(catslug);
        //i = 4;
    }

    function loadMostView(catslug) {
        var noCache = new Date().toString();
        $.getJSON('/Home/loadMostViewByCat?catslug=' + catslug, { noCache: noCache }, function (data) {
            $('#containerMostView').empty();
            $('#containerMostView').append(data);
            $('#container').masonry('reload');
        });
    }
</script>
<div id="section1" class="menu" style="background-color: #f0efef;">
    <div style="float: left; background-color: #f0efef; height: 30px; margin-top: 5px;">
        <img src="@Url.Content("~/Content/Images/MlogThem/mlog-quote-icon.png")" width="22" height="15" alt="blash"/>&nbsp;&nbsp;
    </div>
    <h2>
        xem nhiều nhất</h2>
    <div style="position: absolute; right: 0px; top: 290px;">
        <img src="@Url.Content("~/Content/Images/MlogThem/baiviet-icon.png")" width="27" height="27" alt="bàiviết"  style="cursor: pointer;" onclick="return callLoadMoreByClick('bai-viet');"/>&nbsp;&nbsp;
        <img src="@Url.Content("~/Content/Images/MlogThem/hinhanh-icon.png")" width="27" height="27" alt="hìnhảnh" style="cursor: pointer;" onclick="return callLoadMoreByClick('hinh-anh');"/>&nbsp;&nbsp;
        <img src="@Url.Content("~/Content/Images/MlogThem/video-icon.png")" width="27" height="27" alt="video" style="cursor: pointer;" onclick="return callLoadMoreByClick('video');"/>
    </div>
    <div style="clear: both;">
    </div>
    <div id="containerMostView">
        <ul style="list-style-type: none; background-color: #cbf2fd; margin-top: 0px;">
            @{
                int i = 1;
            }
            @foreach (var post in Model)
            {
            
                <li>
                    @{if (i == 1)
                      {
                        @Html.Partial("PostRecent", post)
                      }
                      else
                      {
                          var url = Url.RouteUrl("IndividualPost", new { year = post.PostYear, month = post.PostMonth, url = post.PostUrl, status = string.Empty });
                          var shortTitle = post.PostTitle.Length > 60 ? string.Format("{0}...", post.PostTitle.Substring(0, 40)) : post.PostTitle;
                          var avatar = string.Empty;
                          if (post.PostAvatarSquare == string.Empty || post.PostAvatarSquare == null || post.PostAvatarSquare.Trim() == "")
                          {
                              avatar = post.PostAvatar;
                          }
                          else
                          {
                              avatar = post.PostAvatarSquare;
                          }
                        <div class="postMostView">
                            <div class="imgLeft">
                                <a href="@url">
                                    <img src="@Url.Content("http://s1.img.yan.vn/Mlog/UploadThumbs/80x80_" + @avatar)" style="border: none 0;" alt="avatar"/></a>
                            </div>
                            <div class="textRight">
                                <a href="@url" title="@post.PostTitle">@shortTitle</a>
                                <br />
                                <div class="boxAuthorViewLike" style="border: 0 none !important;">
                                    <span class="posted" style="float: left;">
                                        <img src="@Url.Content("~/Content/Images/MlogThem/IconView.png")" width="17" height="12" alt="View count"/>&nbsp;@Convert.ToInt32(@post.ViewCount).ToString("#,##0")&nbsp;
                                        <img src="@Url.Content("~/Content/Images/MlogThem/heart-follow.png")" width="12" height="12" alt="like count"/>&nbsp;@Convert.ToInt32(@post.LikeCount).ToString("#,##0")
                                    </span>
                                </div>
                            </div>
                        </div>
                      }
                      i++;
                    }
                </li>
            }
        </ul>
    </div>
</div>
